When a project is canceled all cash spent so far is lost. It is not applied to a newly selected project.

Click on the skull button in the slot of the unwanted project. The slot becomes available. You will be asked to confirm, if you have already spent cash on the project. No confirmation is necessary when you change your mind about a project on the same turn in which you began it.